
package com.zsrt.oa.bank.service.impl;

import java.sql.SQLException;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.zsrt.oa.bank.dao.BankDao;
import com.zsrt.oa.bank.entity.BankEntity;
import com.zsrt.oa.bank.service.BankService;
import com.zsrt.oa.card.dao.CardDao;
import com.zsrt.oa.card.entity.CardEntity;

@Service
public class BankServiceImpl implements BankService {

	@Autowired
	private BankDao dao;
	@Autowired
	private CardDao cDao;
	@Override
	public void findBankById(int id, Map<String, Object> map) {
		
		try {
			BankEntity entity = dao.findBankById(id);
			map.put("result", "success");
			map.put("jieguo", "查询成功...");
			
			map.put("data", entity);
		} catch (Exception e) {
			map.put("result", "failure");
			map.put("jieguo", "查询失败...");
			
			e.printStackTrace();
		}
		
	}
	
	/**
	 * 添加一个银行的时候添加一张表    开启事务
	 */
	@Transactional
	@Override
	public void add(BankEntity entity) {
	
		
		dao.add(entity);
		
		
		CardEntity entity2 = new CardEntity();
		cDao.add(entity2);
			
		
	}


}
